/**
 * Intent that is called to retrieve data from a web service
 * In this prototype application uses the RESTfull service of a
 * Tomcat 6 web app that can be downloaded from :
 * http://code.google.com/p/app4stud/downloads/list
 * and run locally.
 * The web-app on request provides a xml list of :
 * locations and menus.
 *
 */

package fh.app4stud.mensa.webservices;

import android.app.Activity;
import com.sun.org.apache.xerces.internal.util.URI;
import fh.app4stud.mensa.R;
import android.net.*;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by IntelliJ IDEA.
 * User: ivan plese
 * Date: 04.04.11
 * Time: 20:25
 * Version 1.0
 * To change this template use File | Settings | File Templates.
 */
public class Resource extends Activity {

    //Uri data = Uri.parse("content://locations/"+ nearest_location);

    //Find out what is my position
    //Find the closest restaurant on the list
    //get the xml file

    String myFeed = getString(R.string.my_feed);

    void getSomethingFromInternet() {
        try {
            URL url = new URL(myFeed);

            URLConnection connection = url.openConnection();
            HttpURLConnection httpConnection = (HttpURLConnection) connection;

            int responseCode = httpConnection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                InputStream in = httpConnection.getInputStream();
                //add it to the XML resource
            }
        } catch (URI.MalformedURIException e) {
        } catch (IOException e) {
        }
    }
}
